< previous page page_450 next page >

Page 450
z0470-01.gif
Figure 13.30
The normal vector lies along the Y axis.
e10a6a0a59f035e870d90cca05b85fce.gif
 z0470-02.gif
Once you have finished the reflection, apply the inverses of the rotations and translation you performed earlier to move the plane of reflection back to its original position. Suppose T11, R11, and R21 are the inverses of the translation and the first and second rotations respectively. Then the complete transformation for reflecting an object across the plane is given by the matrix equation:
e10a6a0a59f035e870d90cca05b85fce.gif
T R1 R2 S R21 R11 T11
Now you can combine these seven matrices by multiplying them to obtain a single transformation matrix to represent the reflection operation. Module M3Ops.bas contains the subroutine m3Reflect, which uses these methods to initialize a transformation matrix that performs reflection across an arbitrary plane.
e10a6a0a59f035e870d90cca05b85fce.gif
' Create a transformation matrix for reflecting
' across the plane passing through (p1, p2, p3)
' with normal vector <n1, n2, n3>.
Public Sub m3Reflect(M() As Single, ByVal p1 As Single, _
    ByVal p2 As Single, ByVal p3 As Single, _
    ByVal n1 As Single, ByVal n2 As Single, _
    ByVal n3 As Single)
Dim T(1 To 4, 1 To 4) As Single       ' Translate.
Dim R1(1 To 4, 1 To 4) As Single      ' Rotate 1.
Dim R2(1 To 4, 1 To 4) As Single      ' Rotate 2.
Dim S(1 To 4, 1 To 4) As Single       ' Reflect.
Dim R2i(1 To 4, 1 To 4) As Single     ' Unrotate 2.
Dim R1i(1 To 4, 1 To 4) As Single     ' Unrotate 1.
Dim Ti(1 To 4, 1 To 4) As Single      ' Untranslate.
Dim D As Single 
Dim L As Single 
Dim M12(1 To 4, 1 To 4) As Single

 
< previous page page_450 next page >